﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System;
using System.Diagnostics;

#endregion

namespace Sebarf.Diagnostics.Interfaces {
	/// <summary>
	/// Handles invalid condition in the program
	/// </summary>
	public sealed class Check {
		#region Public Properties

		public const int DEBUG = 0;
		public const int ERROR = 1000;
		public const int WARNING = 100;

		/// <summary>
		/// Gets or sets the check implementation
		/// </summary>
		public static ICheckerService CheckImpl { get; set; }

		#endregion

		#region Public Methods

		/// <summary>
		/// checks if the given argument is not null
		/// </summary>
		/// <param name="name"></param>
		/// <param name="argsName"></param>
		/// <exception cref="ArgumentNullException"/>
		public static void ArgumentNotNull(object arg, string argsName) {
			CheckImpl.ArgumentNotNull(arg, argsName);
		}

		/// <summary>
		/// checks if the given condition is false, if so a expection with the given message is generated
		/// </summary>
		/// <param name="condition"></param>
		/// <param name="message"></param>
		public static void AssertException(bool condition, string message) {
			CheckImpl.Assert(ERROR, condition, message);
		}

		/// <summary>
		/// checks if the given condition is false, if so a warning message will be generated
		/// </summary>
		/// <param name="condition"></param>
		/// <param name="message"></param>
		public static void AssertWarning(bool condition, string message) {
			CheckImpl.Assert(WARNING, condition, message);
		}

		/// <summary>
		/// checks if the given condition is false, if so a debug message will be generated
		/// </summary>
		/// <param name="condition"></param>
		/// <param name="message"></param>
		[Conditional("DEBUG")]
		public static void AssertDebug(bool condition, string message) {
			CheckImpl.Assert(DEBUG, condition, message);
		}

		#endregion

		#region Private Methods

		/// <summary>
		/// static ctr
		/// </summary>
		static Check() {
			CheckImpl = new SimpleCheckerService();
		}

		/// <summary>
		/// private ctr
		/// </summary>
		private Check() {
		}

		#endregion
	}
}